<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <h2>姓名：{{getUserName}}</h2>
        <h2>性别：{{getGender}}</h2>
        <h2>标语：{{getHobby}}</h2>
    </div>
    <script src="../../js/vue.js"></script>
    <script>
        const dcl = {
            data() {
                return {
                    firstName: 'Steve',
                    lastName: 'Jobs',
                    isFlag: true,
                    message: 'You are the best'
                }
            },
            // 计算属性与方法的本质区别在于计算属性有缓存
            computed: {
                getUserName() {
                    return this.firstName + this.lastName
                },
                getGender() {
                    return this.isFlag ? '男' : '女'
                },
                getHobby() {
                    return this.message.split('').reverse().join('')
                }
            }
        }
        Vue.createApp(dcl).mount('#app');
    </script>
</body>

</html>